/**
 * 
 */
package com.jsync.service;

import java.util.HashMap;
import java.util.Map;

import com.jsync.model.ResourceProfile;
import com.jsync.model.ResourceQueue;

/**
 * @author prabz
 *
 */
public class ResourceQueueManager {

	private Map<String, ResourceQueue> queueMap;

	/**
	 * @param profile
	 * @return
	 */
	private String getKey(ResourceProfile profile){
		return profile.getSource()+"@"+profile.getDestination();
	}
	
	/**
	 * 
	 */
	public ResourceQueueManager(){
		queueMap = new HashMap<String, ResourceQueue>();
	}
	
	/**
	 * @param profile
	 * @return
	 */
	public ResourceQueue getResourceQueue(ResourceProfile profile){		
		return queueMap.get(getKey(profile));
	}
	
	/**
	 * @param profile
	 * @return
	 */
	public ResourceQueue createResourceQueue(ResourceProfile profile){
		ResourceQueue queue = getResourceQueue(profile);
		if(queue == null){
			queue = new ResourceQueue();
			queueMap.put(getKey(profile), queue);
		}
		return queue;
	}
}
